package com.myapp.init;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.Logger;

import com.myapp.data.global.Instances;

/**
 * Servlet implementation class InitServlet
 */
public class InitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	// 日志
	private Logger log = Logger.getLogger(InitServlet.class);

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public InitServlet() {
		super();
	}

	/**
	 * @see Servlet#init(ServletConfig)
	 */
	public void init(ServletConfig config) throws ServletException {

		// 初始化系统配置
		log.info("Loading App's global config...");
		Instances.getAppConfigBean();

		// 加载基础数据配置
		log.info("Loading App's  data config...");
		Instances.getDataConfigManager().loadDataConfig();

		// 加载基础数据
		log.info("Loading App's data...");
		Instances.getDataConfigManager().loadData();

		// 加载消息
		log.info("Loading App's messages...");
		Instances.getMsgManager().loadMsgConfig();

		// 加载数据库配置
		log.info("Loading App's database config...");
		Instances.getDBConfigManager().initDBConfig();

		// 服务器启动完成
		log.info("Game Server running...");
	}

}
